#include<func.h>
//通过sigaction，打印发送信号的发送者的pid和uid
void sigfunc(int signum,siginfo_t *p,void *p1)
{
    printf("bfer sleep,%d sig is coming,send pid=%d,send uid=%d\n",signum,p->si_pid,p->si_uid);
    sleep(3);
    sigset_t pending;//把内核中pending信号集合取出来
    sigpending(&pending);
    if(sigismember(&pending,SIGQUIT))//判断3号信号是否在pending中
    {
        printf("SIGQUIT is pending\n");
    }
    else{
        printf("SIGQUIT is not pending\n");
    }
    printf("afer sleep,%d sig is coming\n",signum);
}

int main()
{
    struct sigaction act;
    bzero(&act,sizeof(act));//清空
    act.sa_sigaction=sigfunc;//把信号处理函数赋给sa_sigaction
    act.sa_flags=SA_SIGINFO;//代表sa_sigaction生效
    sigemptyset(&act.sa_mask);//清空掩码集合
    sigaddset(&act.sa_mask,SIGQUIT);//填入3号信号，就可以在2号信号函数处理流程中屏蔽3号信号
    int ret=sigaction(SIGINT,&act,NULL);
    ERROR_CHECK(ret,-1,"sigaction")
    while(1);
    return 0;
}